package org.springblade.modules.digitalization.controller;

import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.tool.api.R;
import org.springblade.modules.digitalization.dto.DataExchangeDTO;
import org.springblade.modules.digitalization.dto.ExchangeData;
import org.springblade.modules.digitalization.manager.DataExchangeManager;
import org.springblade.modules.digitalization.vo.CheckResultVo;
import org.springblade.modules.digitalization.vo.DataExchangeVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@RestController
@RequestMapping("/data-exchange")
public class DataExchangeController extends BladeController {


	@Autowired
	private DataExchangeManager dataExchangeManager;

	@GetMapping("/list")
	public List<DataExchangeVO> list(@RequestParam(value = "createUserId", defaultValue = "") Long createUserId) {
		List<DataExchangeVO> data = dataExchangeManager.list(createUserId);
		return data;
	}

	@PostMapping
	public void add(@RequestBody DataExchangeDTO dataExchangeDTO) {
		dataExchangeManager.addData(dataExchangeDTO);
	}

	@DeleteMapping("/{a0000}")
	public void remove(@PathVariable("a0000") String a0000) {
		dataExchangeManager.remove(a0000);
	}

	@DeleteMapping("/finished")
	public void remove() {
		dataExchangeManager.removeFinished();
	}

	@GetMapping("/retry/{a0000}")
	public void reTry(@PathVariable("a0000") String a0000) {
		dataExchangeManager.reAdd(a0000);
	}


	@GetMapping("/check")
	public R<Integer> checkDataExchange() {
		int i = dataExchangeManager.checkDataExchange();
		return R.data(i);
	}

}
